home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************************
-
-
- This routine makes a QTVR Navigable Movie from a Quickdraw3D model.
-
-
- *************************************************************************************************/
- #include "QD3DtoQTVR.h"
- #include "extern.h"
- #include "NavMovie.h"
- #include "object.h"
- #include "draw.h"
- #include "document.h"
- #include "file.h"
- #include "AEVT.h"
- #include "MyMovies.h"
- #include "camera.h"
-
- void MyConvert3DMFToObject(FSSpec *myFSS)
- {
- DocumentPtr theDocument;
-
- // Create the document record and make the view and camera
- theDocument = MyNewDocument();
- if (!theDocument)
- return;
-
- // Read the model and add it to the document record's group
- if(MyOpenFile(myFSS, theDocument)) {
- MyCloseDocument(theDocument);
- return;
- }
-
- // Set up the initial camera position for object rendering
- MyInitObjCamera(theDocument);
-
- // Draw to the screen
- MyDrawOffScreen(theDocument);
- MyDrawOnScreen(theDocument);
-
- // Assign the Codec type
- theDocument->theCodecType = kMyCodec;
-
- // Generate all the images and add them to the linear movie
- MyGenerateObjImages(theDocument,36,19,360,0,90,-90); // note this means 36 rows, 18 columns
-
- // Clean up
- MyCloseDocument(theDocument);
- }
-
- void MyGenerateObjImages(DocumentPtr theDocument,short rows,short columns,
- long maxHPan,long minHPan,long maxVPan,long minVPan)
- {
- GWorldPtr oldPort;
- GDHandle oldGD;
- float xStart,yStart,xStep,yStep;
- Boolean wrap = false;
- float xAngle,yAngle;
-
- GetGWorld(&oldPort,&oldGD);
- SetGWorld(theDocument->theWindow,nil);
-
- // Create empty linear object movie
- if(MyPrepareDestMovie(theDocument))
- return;
-
- if(maxHPan == 360 && minHPan == 0) {
- maxHPan = 350;
- wrap = true;
- }
-
- // Assign stepping angles
- if(maxVPan == minVPan || rows == 1)
- yStep = 1;
- else
- yStep = ((float)(maxVPan-minVPan))/(float)(rows-1);
-
- if(maxHPan == minHPan || columns == 1)
- xStep = 1;
- else
- xStep = ((float)(maxHPan-minHPan))/(float)(columns-1);
-
- for(yAngle = maxVPan; yAngle >= minVPan; yAngle -= yStep) {
- for(xAngle = 0;xAngle <= maxHPan-minHPan; xAngle += xStep) {
- if(Button())
- break;
-
- // Rotate the object to the correct position
- xStart = (-kQ3Pi* ( xAngle - ((float)(maxHPan-minHPan))/2.0) )/180.0;
- yStart = kQ3Pi*((float)yAngle)/180.0;
- MyRotateObjectY(theDocument,xStart);
- MyRotateObjectX(theDocument,yStart);
-
- // Render the model (to get a PixMap image).
- MyDrawOffScreen(theDocument);
- MyDrawOnScreen(theDocument);
-
- // Add the rendered PixMap to the linear movie.
- if(MyAddImageToMovie(theDocument)) break;
-
- //Undo the rotation
- MyRotateObjectX(theDocument,-yStart);
- MyRotateObjectY(theDocument,-xStart);
- }
-
- }
-
- MyDrawOffScreen(theDocument);
- MyDrawOnScreen(theDocument);
-
- MyCloseDestMovie(theDocument);
-
- SetGWorld(oldPort,oldGD);
- }
-
-
-
-